﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZF.Model;
using ZF.BLL;
using GCELibrary.Current;
using ZF.BLL.Linq;
using ZF.DAL;
using System.Web.UI.HtmlControls;

namespace ZF.WS.info
{
    public partial class view : BLL.Page.PageBase
    {
        [PageArgument(Key = "id", CanNull = false)]
        public int Id { get; set; }

        public Model.I_Info Info { get; set; }
        protected void Page_Load(object sender, EventArgs e)
        {
            using (var dc = SiteInfo.CreateDBDataContext())
            {
                var iq = dc.I_Info.Where(p=>true);
                if (!(SiteInfo.GetCurrentMember() != null && SiteInfo.GetCurrentMember().UserType == UserType.Admin))
                {
                    iq = iq.Where(p => p.IsVerify);
                }
                var info = iq.FirstOrDefault(p => p.InfoId == Id);
                if (info == null)
                {
                    throw WarnFactory.CreateWarn("未找到该分类信息，可能该分类信息已经被删除", WarnIcon.Error, WarnLink.GoDefault);
                }
                Info = info;
                var ps = info.Photo.EmptyString("").Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                if (ps.Length > 0)
                {
                    this.lvImgList.DataSource = ps.Select(p => new { File = p }).ToList();
                    this.lvImgList.DataBind();
                }
                else
                    this.tyPhoto.Visible = false;

            }

        }
        public string City
        {
            get
            {
                return DictionaryConfig.HArea.DefaultIfEmpty(p => p.AreaId == Info.AreaId1,
                    new Dic_Area() { Name = "其他" }).Name;
            }
        }
        public string Area
        {
            get
            {
                return DictionaryConfig.HArea.DefaultIfEmpty(p => p.AreaId == Info.AreaId1,
                    new Dic_Area() { Name = "" }).Name;
            }
        }
    }
}
